package com.credithc.signature.common.utils;

import com.credithc.signature.common.po.FddConfig;
import com.credithc.signature.common.service.FddConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @author zhanghanqiu181212@credithc.com
 * @Date 2020/9/15 10:42
 */

@Service
public class FddConfigMap implements CommandLineRunner {

    private static HashMap<String, FddConfig> configMap = new HashMap<>(16);

    @Autowired
    private FddConfigService fddConfigService;

    public static HashMap<String, FddConfig> getConfig() {
        return configMap;
    }

    @Override
    public void run(String... args) throws Exception {
        List<FddConfig> allConfig = fddConfigService.getAllConfig();
        for (FddConfig f : allConfig) {
            configMap.put(f.getChannelId(), f);
        }
    }
}
